<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>写文章</title>
  <link rel="stylesheet" href="/assets/css/iconfont.css">
  <link rel="stylesheet" href="/assets/libs/bootstrap.min.css">

  <link rel="stylesheet" href="/assets/css/base.css">
  <link rel="stylesheet" href="/assets/css/ad-public.css">
  <link rel="stylesheet" href="/assets/css/ad-public.css">
  <link rel="stylesheet" href="/assets/css/post-add.css">

</head>

<body>

  <!-- 侧边栏 -->
  @@include('../assets/common/admin/adminNav.html')


  <!-- 主体 -->
  <div class="main">
    <!-- 头部 -->
    @@include('../assets/common/admin/adminMainHeader.html')
    <!-- 内容区 -->
    <div class="content">
      <div class="page-title">
        <h3>写文章</h3>
      </div>

      <form class="row" id="addForm">
        <div class="col-md-9">
          <div class="form-group">
            <label for="title">标题</label>
            <input id="title" name="title" class="form-control input-lg" type="text" placeholder="文章标题">
          </div>
          <div class="form-group">
            <label for="content">内容</label>
            <textarea id="content" name="content" class="form-control input-lg" cols="30" rows="10"
              placeholder="内容"></textarea>
          </div>
        </div>

        <div class="col-md-3">
          <div class="form-group">
            <label for="feature">文章封面</label>
            <!-- show when image chose -->
            <img class="help-block thumbnail" style="display: none">
            <input id="feature" class="form-control" type="file" name="">
            <input id="thumbnail" name="thumbnail" class="form-control" type="hidden">
          </div>
          <div class="form-group">
            <label for="category">所属分类</label>
            <select id="category" name="category" class="form-control">

            </select>
          </div>
          <div class="form-group">
            <label for="created">发布时间</label>
            <input id="created" class="form-control" name="createAt" type="date">
          </div>
          <div class="form-group">
            <label for="status">状态</label>
            <select id="status" name="state" class="form-control">
              <option value="0">草稿</option>
              <option value="1">已发布</option>
            </select>
          </div>
          <div class="form-group">
            <button class="btn btn-primary" type="submit">保存</button>
          </div>
        </div>
      </form>


    </div>
  </div>

  @@include('../assets/common/adminBase.html')
  <!-- 分类模板 -->
  <script type="text/template" id="cateTemplate">
    {{each result}}
    <option value="{{$value._id}}" >{{$value.title}}</option>
    {{/each}}
  </script>

  <!-- 编辑文章模板 -->
  <script type="text/template" id="editTemplate">
    <form class="row" id="editForm" >
      <div class="col-md-9">
        <div class="form-group">
          <label for="title">标题</label>
          <input id="title" name="title" value="{{res.title}}" class="form-control input-lg" type="text" placeholder="文章标题">
        </div>
        <div class="form-group">
          <label for="content">内容</label>
          <textarea id="content" name="content" class="form-control input-lg" cols="30" rows="10"
            placeholder="内容">{{res.content}}</textarea>
        </div>
      </div>

      <div class="col-md-3">
        <div class="form-group">
          <label for="feature">文章封面</label>
          <!-- show when image chose -->
          <img class="help-block thumbnail" style="display: none">
          <input id="feature" class="form-control" type="file" name="">
          <input id="thumbnail" name="thumbnail" value="{{res.thumbnail}}" class="form-control" type="hidden">
        </div>
        <div class="form-group">
          <label for="category">所属分类</label>
          <select id="category" name="category"  class="form-control">
            {{each res.categories}}
            <option {{res.category._id ==$value._id ? "selected" : ""}} value="{{res.category._id}}">{{$value.title}}</option>
          {{/each}}
        </select>
          </select>
        </div>
        <div class="form-group">
          <label for="created">发布时间</label>
          <input id="created" class="form-control" name="createAt" value="{{res.createAt.split('T')[0]}}" type="date">
        </div>
        <div class="form-group">
          <label for="status">状态</label>
          <select id="status" name="state" class="form-control">
            <option value="0" {{res.state==0?"selected":""}}>草稿</option>
            <option value="1" {{res.state==1?"selected":""}}>已发布</option>
          </select>
        </div>
        <div class="form-group">
          <button class="btn btn-primary edit" type="submit">修改</button>
        </div>
      </div>
    </form>
  </script>

  <script src="../js/admin/post-add.js"></script>

</body>

</html>